using System;
using System.Collections.Generic;
using System.Text;
using Qreed.Windows.ComponentModel;

namespace PropertyBagDemo
{
    class TestClass
    {
        public TestClass()
        {
            _bag = CreateMp3FilePropertyBag(@"d:\My Music\1.mp3", "Madonna", "Like a slettebek", 1, true);

            // Multiple items
            /*
            _bags.Add(CreateMp3FilePropertyBag(@"d:\My Music\1.mp3", "Madonna", "Like a slettebek", 1, false));
            _bags.Add(CreateMp3FilePropertyBag(@"d:\My Music\2.mp3", "Madonna", "Vakantie!!", 2, false));

            PropertyBag[] bagsArray = new PropertyBag[_bags.Count];
            _bags.CopyTo(bagsArray);*/
        }

        private PropertyBag _bag;

        public PropertyBag Bag
        {
            get { return _bag; }
            set { _bag = value; }
        }
	
        private PropertyBag CreateMp3FilePropertyBag(string filename, string artist, string title, int trackNum, bool expandable)
        {
            PropertyBag bag = null;

            if (expandable)
                bag = new PropertyBag(filename, filename, "Track information", "Blaha Description", false, true);
            else
                bag = new PropertyBag();

            FillMp3FilePropertyBag(filename, artist, title, trackNum, bag);

            return bag;
        }

        private static void FillMp3FilePropertyBag(string filename, string artist, string title, int trackNum, PropertyBag bag)
        {
            bag.Add(new PropertyBagItem("Filename", filename, "File information", "The filename.", true, true, typeof(string)));
            bag.Add(new PropertyBagItem("Tracknum", trackNum, "Track information", "The track number.", false, true, typeof(int)));
            bag.Add(new PropertyBagItem("Artist", artist, "Track information", "The artist of the song.", false, true, typeof(string)));
            bag.Add(new PropertyBagItem("Title", title, "Track information", "The title of the song.", false, true, typeof(string)));
        }

        void bag_SetValue(object sender, PropertyBagEventArgs e)
        {

            //propertyGrid1.Refresh();

        }


    }
}
